package org.shiro.bean;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
/** @author HKC */
@Data
public class JsonResult implements Serializable {
  @ApiModelProperty(name = "是否成功")
  private boolean success;

  @ApiModelProperty(name = "页面信息")
  private String message;

  @ApiModelProperty(name = "数据")
  private Object data;

  public static JsonResult success(String message) {
    JsonResult res = new JsonResult();
    res.setSuccess(true);
    res.setMessage(message);
    return res;
  }

  public static JsonResult success(String message, Object data) {
    JsonResult res = new JsonResult();
    res.setSuccess(true);
    res.setMessage(message);
    res.setData(data);
    return res;
  }

  public static JsonResult failure(String message) {
    JsonResult res = new JsonResult();
    res.setSuccess(false);
    res.setMessage(message);
    return res;
  }

  public static JsonResult failure(String message, Object data) {
    JsonResult res = new JsonResult();
    res.setSuccess(false);
    res.setMessage(message);
    res.setData(data);
    return res;
  }
}
